package com.kotlin.flong.base1

/**
 * @Author:liangjl
 * @Date: 2020/6/16-20:46
 * @Eamil:jilongliang@sina.com
 * @Description: constructor构造方法
 */
class Person constructor(username: String) {
    private var username: String? = null
    private var age: Int? = null
    private var address: String? = null

    init {
        println(username)
        this.username = username
        this.age = 20
        this.address = "广东省云浮市"
    }

    constructor(username: String, age: Int) : this(username) {
        println("$username,$age")
        this.username = username
        this.age = age
        this.address = "广东省云浮市"
    }

    constructor(username: String, age: Int, address: String) : this(username, age) {
        this.address = address
    }

    fun printInfo() {
        println("username=${this.username},age=${this.age},adddress=${this.address}")
    }

}

fun main() {
    val p1 = Person("task")
    val p2 = Person("task1", 28)
    val p3 = Person("task1", 27, "ɽ")

    p1.printInfo()
    p2.printInfo()
    p3.printInfo()
}